package com.antjupt.servlet;
/**
 * @author Wizarder
 * @create 2021-05-25 15:31
 */

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.IOException;

public class ContextServlet3 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        ServletContext servletContext = getServletContext();
        System.out.println(servletContext);//与ContextServlet2中的地址相同
        System.out.println("保存之前的值：" + servletContext.getAttribute("key1"));
        servletContext.setAttribute("key2","value2");
        System.out.println("保存之后的值：" + servletContext.getAttribute("key2"));
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
